<?php
require('config.php');

        $user_id=$_REQUEST['user_id'];
        $json=$_REQUEST['json'];
        $json=json_decode($json,true);
		$sql="select * from `".$oto."_users` where `userId`='".$user_id."' LIMIT 1";
		$result=$db->query($sql);
		while($row=$result->fetch_assoc()){
			$user_info[]=$row;//将取得的所有数据赋值给person_info数组
		}
		$data[0]['userMoney']=$user_info[0]['userMoney'];
		if($user_info[0]['payPwd']==NULL || $user_info[0]['payPwd']=="" || is_null($user_info[0]['payPwd']))
		{
			$data[0]['payPwd']=0;
		}
		else
		{
			$data[0]['payPwd']=1;
		}
		$pay_money=0;
		$goodsNames='';
		$goodsNames_num=0;
		for($i=0;$i<count($json);$i++)
		{
			$order_id=$json[$i]['orderId'];
			$sql="select * from `".$oto."_orders` where `orderId`='".$order_id."' LIMIT 1";
			$result=$db->query($sql);
			while($row=$result->fetch_assoc()){
				$order[$i]=$row;//将取得的所有数据赋值给person_info数组
			}
			$sql="select * from `".$oto."_order_goods` where `orderId`='".$order_id."'";
			$result=$db->query($sql);
			while($row=$result->fetch_assoc()){
				$order_goods[$i][]=$row;//将取得的所有数据赋值给person_info数组
			}
			//$pay_money+=$order[$i]['needPay']+$order[$i]['deliverMoney'];
			$pay_money+=$order[$i]['needPay'];
			$data[$i]['orderId']=$order_id;
			for($j=0;$j<count($order_goods[$i]);$j++)
			{
				$data[$i]['order_goods_list'][$j]['goodsNums']=$order_goods[$i][$j]['goodsNums'];
				$data[$i]['order_goods_list'][$j]['goodsAttrName']=$order_goods[$i][$j]['goodsAttrName'];
				$data[$i]['order_goods_list'][$j]['goodsName']=$order_goods[$i][$j]['goodsName'];
				$data[$i]['order_goods_list'][$j]['goodsPrice']=$order_goods[$i][$j]['goodsPrice'];
				if($goodsNames_num==0) $goodsNames.=$order_goods[$i][$j]['goodsName'];
				else $goodsNames.=','.$order_goods[$i][$j]['goodsName'];
				$goodsNames_num++;
			}
		}
		$data[0]['needPay']=$pay_money;
		$data[0]['goodsNames']=$goodsNames;
		echo json_encode($data);
?>